#PBS -N 04-02_salmon
#PBS -A GT-wratcliff3
#PBS -q inferno
#PBS -j oe
#PBS -o logs/04-02_salmon.out
    
# change to project directory
PROJECT_DIR=$PBS_O_WORKDIR
echo "Changing directory to ${PROJECT_DIR}…"
cd $PROJECT_DIR
     
# activate environment
PIPELINE_ENV=`basename scripts/*.yml .yml`
echo "Activating conda environment ${PIPELINE_ENV}…"
source activate $PIPELINE_ENV
    
# extract sample name
samplenames=(`cat raw_data/samplenames.txt`)
sampleindex=$PBS_ARRAYID
samplename=${samplenames[$(($sampleindex-1))]}
     
echo -e "\n########## Start processing sample ${sampleindex}: ${samplename} ##########\n"

echo -e "\n########## Starting Salmon ##########\n"

# ref
salmon_transcriptome_index=/storage/home/hcoda1/6/ktong34/p-wratcliff3-0/ngs_ref/ref_index/ensembl_release-103_Scer/salmon_v1.4.0_transcriptome_index/kmer-length-31

# input/output
in=results/03A_sortmerna/out
in_R1=$in/${samplename}_rRNA_filtered_R1.fastq.gz
in_R2=$in/${samplename}_rRNA_filtered_R2.fastq.gz
out=results/04-02_salmon/$samplename
mkdir -p $out

# main
salmon quant \
-l A \
-1 $in_R1 -2 $in_R2 \
-i $salmon_transcriptome_index \
-o $out \
--useVBOpt \
--seqBias \
--gcBias \
--validateMappings \
-p $PBS_NP

